package com.srwl.mytx.domain;

import android.os.Parcel;
import android.os.Parcelable;

import com.srwl.mytx.domain.LatLng;
import com.srwl.mytx.domain.User;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 捐赠转发  实体类
 */
public class Forward implements Parcelable {
    private String fId;

    private String manager;

    private String tId;

    private String oId;

    private Double amount;

    private Double donationAmount;//没有经过主题转发，直接捐赠给用户的金额总计

    private String title;

    private String reason;

    private String receipt;

    private String video;

    private String videoCover;

    private List<String> pictures;

    private String address;

    private LatLng location;

    private Integer commentSize;

    private Integer praiseSize;

    private Integer status;

    private Integer type;

    private Date updated;

    private Date created;

    private Topic attachTopic;//该笔转发所依附的主题

    private User targetUser;//当受赠人查询受赠记录的时候，该用户信息为 主题的管理员用户信息(经办人)；当其他人查看该笔转赠信息的时候，该用户信息为受赠人信息

    private User managerUser;

    private List<MyFile> myFileList;

    private boolean hadPraise;  //标记当前用户是否对该条转发点赞

    public Forward(String fId, String manager, String tId, String oId, Double amount, Double donationAmount, String title, String reason, String receipt, String video, List pictures, String address, LatLng location, Integer commentSize, Integer praiseSize, Integer status, Integer type, Date updated, Date created) {
        this.fId = fId;
        this.manager = manager;
        this.tId = tId;
        this.oId = oId;
        this.amount = amount;
        this.donationAmount = donationAmount;
        this.title = title;
        this.reason = reason;
        this.receipt = receipt;
        this.video = video;
        this.pictures = pictures;
        this.address = address;
        this.location = location;
        this.commentSize = commentSize;
        this.praiseSize = praiseSize;
        this.status = status;
        this.type = type;
        this.updated = updated;
        this.created = created;
    }

    public Forward() {
        super();
    }

    public String getfId() {
        return fId;
    }

    public void setfId(String fId) {
        this.fId = fId == null ? null : fId.trim();
    }

    public String getManager() {
        return manager;
    }

    public void setManager(String manager) {
        this.manager = manager == null ? null : manager.trim();
    }

    public String gettId() {
        return tId;
    }

    public void settId(String tId) {
        this.tId = tId == null ? null : tId.trim();
    }

    public String getoId() {
        return oId;
    }

    public void setoId(String oId) {
        this.oId = oId == null ? null : oId.trim();
    }

    public Double getAmount() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

    public Double getDonationAmount() {
        return donationAmount;
    }

    public void setDonationAmount(Double donationAmount) {
        this.donationAmount = donationAmount;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title == null ? null : title.trim();
    }


    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason == null ? null : reason.trim();
    }

    public String getReceipt() {
        return receipt;
    }

    public void setReceipt(String receipt) {
        this.receipt = receipt == null ? null : receipt.trim();
    }

    public String getVideo() {
        return video;
    }

    public void setVideo(String video) {
        this.video = video == null ? null : video.trim();
    }

    public String getVideoCover() {
        return videoCover;
    }

    public void setVideoCover(String videoCover) {
        this.videoCover = videoCover;
    }

    public List<String> getPictures() {
        if (pictures == null) {
            pictures = new ArrayList<>();
        }
        return pictures;
    }

    public void setPictures(List<String> pictures) {
        this.pictures = pictures;
    }

    public Integer getCommentSize() {
        return commentSize;
    }

    public void setCommentSize(Integer commentSize) {
        this.commentSize = commentSize;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public LatLng getLocation() {
        return location;
    }

    public void setLocation(LatLng location) {
        this.location = location;
    }

    public Integer getPraiseSize() {
        return praiseSize;
    }

    public void setPraiseSize(Integer praiseSize) {
        this.praiseSize = praiseSize;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Date getUpdated() {
        return updated;
    }

    public void setUpdated(Date updated) {
        this.updated = updated;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Topic getAttachTopic() {
        return attachTopic;
    }

    public void setAttachTopic(Topic attachTopic) {
        this.attachTopic = attachTopic;
    }

    public User getTargetUser() {
        return targetUser;
    }

    public void setTargetUser(User targetUser) {
        this.targetUser = targetUser;
    }

    public User getManagerUser() {
        return managerUser;
    }

    public void setManagerUser(User managerUser) {
        this.managerUser = managerUser;
    }

    public boolean isHadPraise() {
        return hadPraise;
    }

    public void setHadPraise(boolean hadPraise) {
        this.hadPraise = hadPraise;
    }

    public List<MyFile> getMyFileList() {
        return myFileList;
    }

    public void setMyFileList(List<MyFile> myFileList) {
        this.myFileList = myFileList;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.fId);
        dest.writeString(this.manager);
        dest.writeString(this.tId);
        dest.writeString(this.oId);
        dest.writeValue(this.amount);
        dest.writeValue(this.donationAmount);
        dest.writeString(this.title);
        dest.writeString(this.reason);
        dest.writeString(this.receipt);
        dest.writeString(this.video);
        dest.writeStringList(this.pictures);
        dest.writeString(this.address);
        dest.writeParcelable(this.location, flags);
        dest.writeValue(this.commentSize);
        dest.writeValue(this.praiseSize);
        dest.writeValue(this.status);
        dest.writeValue(this.type);
        dest.writeLong(this.updated != null ? this.updated.getTime() : -1);
        dest.writeLong(this.created != null ? this.created.getTime() : -1);
        dest.writeParcelable(this.attachTopic, flags);
        dest.writeParcelable(this.targetUser, flags);
        dest.writeParcelable(this.managerUser, flags);
        dest.writeTypedList(this.myFileList);
    }

    protected Forward(Parcel in) {
        this.fId = in.readString();
        this.manager = in.readString();
        this.tId = in.readString();
        this.oId = in.readString();
        this.amount = (Double) in.readValue(Double.class.getClassLoader());
        this.donationAmount = (Double) in.readValue(Double.class.getClassLoader());
        this.title = in.readString();
        this.reason = in.readString();
        this.receipt = in.readString();
        this.video = in.readString();
        this.pictures = in.createStringArrayList();
        this.address = in.readString();
        this.location = in.readParcelable(LatLng.class.getClassLoader());
        this.commentSize = (Integer) in.readValue(Integer.class.getClassLoader());
        this.praiseSize = (Integer) in.readValue(Integer.class.getClassLoader());
        this.status = (Integer) in.readValue(Integer.class.getClassLoader());
        this.type = (Integer) in.readValue(Integer.class.getClassLoader());
        long tmpUpdated = in.readLong();
        this.updated = tmpUpdated == -1 ? null : new Date(tmpUpdated);
        long tmpCreated = in.readLong();
        this.created = tmpCreated == -1 ? null : new Date(tmpCreated);
        this.attachTopic = in.readParcelable(Topic.class.getClassLoader());
        this.targetUser = in.readParcelable(User.class.getClassLoader());
        this.managerUser = in.readParcelable(User.class.getClassLoader());
        this.myFileList = in.createTypedArrayList(MyFile.CREATOR);
    }

    public static final Creator<Forward> CREATOR = new Creator<Forward>() {
        @Override
        public Forward createFromParcel(Parcel source) {
            return new Forward(source);
        }

        @Override
        public Forward[] newArray(int size) {
            return new Forward[size];
        }
    };
}